home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / infoserv / www / cern / dev / www-talk.9301-9306.Z / www-talk.9301-9306 / text0798.txt < prev    next >
Encoding:
Text File  |  1995-04-24  |  1.1 KB  |  27 lines

  1. Thus wrote: 
  2. >I have a couple of HTML servers written in perl, running
  3. >under SunOS Unix, invoked via inetd.
  4. >
  5. >Is there a way in perl to find out the internet address of the client?
  6. >Or do I have to give up the convenience of inetd to do that?
  7.  
  8. I have an HTTP server written in perl, under SunOS Unix, as a
  9. standalone daemon without inetd.  I considered inetd but am of the
  10. opinion that the performance would be unacceptable if perl had to
  11. parse the whole thing for every request.  Forks are not that expensive
  12. in perl, and probably will be faster once we convert to a OpSys with
  13. copy-on-write.  Thus, the code from mine looks more or less like the
  14. code on page 345 of the Camel book.  It's running; URL
  15. http://cs.indiana.edu/ if you want to peek.  I plan to release the
  16. code once it's stable, though people can have unstable copies if they
  17. really want.
  18.  
  19. The following code is taken from page 153 of the Camel book, and
  20. probably does what you want:
  21.  
  22.   $sockaddr = 'S n a4 x8';
  23.   $mysockaddr = getsockname(S);
  24.   ($family, $port, $myaddr) = unpack($sockaddr, $mysockaddr);
  25.  
  26. - Marc
  27.